#include"apue.h"
//#include<getch.h>
using namespace std;
using namespace MC;
const char* superpasswd="000000";


//登录入口
void M::run(void)
{
	Tools tools;
	tools.init_id(ID_PATH,1000);
	while(1)
	{
		switch(menu())
		{
			case SUPER:supermanager_login(); break;
			case SERVICE: servicemanager_login();break;
			case QUITSYS: return;
		}
	}
}

int M::menu(void)
{

	system("clear");
 	puts("╭═════════════════════■□■□══════════╮");  
    puts("│      Manager         system       │");  
    puts("╰════════════■□■□═══════════════════╯");  
	puts("————【1】超级管理员*****【2】业务管理员————");
	puts("—————————————————————————————————————");
	puts("—————————————————————————————————————");
	puts("—————————————【3】退出—————————————————");
	//int cmd;
	//cin>>cmd;
	char ch=getch();
	return ch-'0'+14;
}

//超级管理员登录
void M::supermanager_login(void)
{
	cout<<"欢迎您超级管理员！"<<endl;
	cout<<"请输入登录密码:"<<endl;
	Tools tools;
	char passwd[20];
	while(1)
	{
		strcpy(passwd,tools.get_pwd(passwd,sizeof(passwd)));
		if(strcmp(passwd,superpasswd)==0)
		{
			ManagerViewConsoleimpl Service;
			Service.run();
			break;
		}
		else
		{
			cout<<"密码错误，请核对后输入："<<endl;
		}
	}


}

//业务管理员登录
void M::servicemanager_login(void)
{
	cout<<"欢迎您业务管理员！"<<endl;
	cout<<"请输入登录密码:"<<endl;
	Tools tools;
	char passwd[20];
	
	while(1)
	{
		strcpy(passwd,tools.get_pwd(passwd,sizeof(passwd)));
		if(strcmp(passwd,superpasswd)==0)
		{
			ServiceViewConsoleImpl Service;
			Service.run();
			break;
		}
		else
		{
			cout<<"密码错误，请核对后输入："<<endl;
		}
	}

}


